/*
 * @Date: 2019-08-31 11:43:26
 * @Github: https://github.com/FinnWu
 * @LastEditors: Finnwu
 * @LastEditTime: 2019-08-31 11:51:42
 */

function ListNode(x){
    this.val = x;
    this.next = null;
}

// 从头到尾打印链表
function printListFromTailToHead(head){
    // write code here
    var current = head
    var arr = []
    while(current) {
        arr.push(current.val)
        current = current.next
    }
    arr.reverse()
    return arr
}

var list = new ListNode(1)
list.next = new ListNode(2)
list.next.next = new ListNode(3)
console.log(printListFromTailToHead(list))
